<?php


namespace App\Models\ProductCenter\Models;


use App\Models\ProductCenter\ProductModel;

class CarouselModel extends ProductModel
{
    public $table = 'carousel';

    public $fillable = [
        'type', //int NOT NULL DEFAULT '0' COMMENT '系统参数id',
        'title', //varchar(64) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '标题',
        'describe', //varchar(255) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '描述',
        'image_url',
        'url', //varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'url',
        'status', //tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态 1=正常 2禁用',
        'sort',
        'create_user', //varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '创建者',
        'create_user_uuid', //varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '创建者uuid',
//        'create_time', //datetime DEFAULT NULL COMMENT '创建时间',
//        'update_time', //datetime DEFAULT NULL COMMENT '更新时间',
    ];

    public function params()
    {
        return $this
            ->hasOne(SystemTypeModel::class, 'id', 'type')
            ->select(['id', 'label', 'value'])
            ->withDefault();
    }

    public function getCarouselInfo($where)
    {
        return $this
            ->handleCondition($where)
            ->with(['params'])
            ->first();
    }
}
